package com.clothes.aweiDoExercises.config;

import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@ConfigurationProperties(prefix = "spring.redis")
@Data
public class RedissonConfig {
    private String host;//redis主机名
    private int port;//redis端口
    //private String password;//redis密码,我是这里没有设置密码，如果需要密码，可以在这里设置
    private int database;//指定redis数据库号

    @Bean
    public  RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://"+host+":"+port)
                //.setPassword(password)
                .setDatabase(database);
        return Redisson.create(config);
    }
}
